﻿using System.Globalization;
using System.Threading;
using CB.Stock.Data.Yahoo;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using CB.Stock.Core;

namespace Testing
{
    
    
    /// <summary>
    ///This is a test class for YahooDynamicDataTest and is intended
    ///to contain all YahooDynamicDataTest Unit Tests
    ///</summary>
    [TestClass()]
    public class YahooDynamicDataTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for YahooDynamicData`1 Constructor
        ///</summary>
        public void YahooDynamicDataConstructorTestHelper<T>()
        {
            StockDataType dataType = StockDataType.SalePrice; // TODO: Initialize to an appropriate value
            Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("de");
            var value = 1.334; // TODO: Initialize to an appropriate value
            DateTime time = DateTime.Now; // TODO: Initialize to an appropriate value
            DefaultDynamicData<double> target = new DefaultDynamicData<double>(dataType, value, time);
            Assert.AreEqual(1.334, target.Data, "YahooDynamicData<double> Construct Fail --- Data");
            Assert.AreEqual(time, target.Time, "YahooDynamicData<double> Construct Fail --- Time");
            Assert.AreEqual(dataType, target.DataType, "YahooDynamicData<double> Construct Fail --- DataType");
        }

        [TestMethod()]
        public void YahooDynamicDataConstructorTest()
        {
            YahooDynamicDataConstructorTestHelper<GenericParameterHelper>();
        }

        /// <summary>
        ///A test for YahooDynamicData`1 Constructor
        ///</summary>
        public void YahooDynamicDataConstructorTest1Helper<T>()
        {
            StockDataType dataType = StockDataType.SalePrice; // TODO: Initialize to an appropriate value
            var value = 0.022; // TODO: Initialize to an appropriate value
            var time = DateTime.Now;
            DefaultDynamicData<double> target = new DefaultDynamicData<double>(dataType, value);
            Assert.AreEqual(0.022, target.Data, "YahooDynamicData<double> Construct Fail --- Data");
            Assert.IsTrue((target.Time - time) < TimeSpan.FromSeconds(1),
                          "YahooDynamicData<double> Construct Fail --- Time");
            Assert.AreEqual(dataType, target.DataType, "YahooDynamicData<double> Construct Fail --- DataType");
        }

        [TestMethod()]
        public void YahooDynamicDataConstructorTest1()
        {
            YahooDynamicDataConstructorTest1Helper<GenericParameterHelper>();
        }
    }
}
